<template>
	<view class="page">
		<view class="actions">
			<text class="text" :class="{active:item.key===curr}" @click="switchAction(item.key)" :key="index"
				v-for="(item,index) in actions">{{item.name}}</text>
		</view>
		<view class="counts">
			<view class="count">
				<text class="number">{{countInfo.amount || 0}}</text>
				<text class="text">佣金</text>
			</view>
			<view class="count">
				<text class="number">{{countInfo.count || 0}}</text>
				<text class="text">数量</text>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				curr: 'today',
				pId: 0,
				actions: [{
						key: 'today',
						name: '今天'
					},
					{
						key: 'yesterday',
						name: '昨天'
					},
					{
						key: 'last_three_days',
						name: '最近三天'
					},
					{
						key: 'last_seven_days',
						name: '最近7天'
					},
					{
						key: 'month',
						name: '本月7天'
					},
					{
						key: 'last_month',
						name: '上月'
					},
					{
						key: 'year',
						name: '今年'
					},
					{
						key: 'last_year',
						name: '去年'
					},
				],
				countInfo: {},
			}
		},
		onLoad(option) {
			this.pId = option.id
			this.getData()
		},
		methods: {
			switchAction(action) {
				this.curr = action;
				this.getData()
			},
			getData() {
				this.$api.sendRequest({
					url: '/api/member/accountStatistics',
					data: {
						partner_id: this.pId,
						day: this.curr
					},
					success: res => {
						console.log(res);
						this.countInfo = res.data

					}
				})
			}

		}
	}
</script>

<style lang="scss">
	.page {
		padding: 60rpx 45rpx;
		background-color: #F8F8F8;

	}

	.actions {
		margin-bottom: 30rpx;
		background-color: #FFFFFF;
		box-shadow: 0 0 4rpx 4rpx #EEEEEE;
		padding: 30rpx;

		.text {
			display: inline-block;
			color: #FFFFFF;
			background-color: #CCCCCC;
			padding: 6rpx 15rpx;
			margin-right: 30rpx;
			margin-bottom: 20rpx;
			border-radius: 6rpx;

			&.active {
				background-color: #1786F8;
				font-weight: 700;
			}
		}
	}

	.counts {
		box-shadow: 0 0 4rpx 4rpx #EEEEEE;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		background-color: #FFFFFF;

		.count {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			width: 260rpx;


			.number {
				font-size: 80rpx;
				color: #000000;
				font-weight: 900;
			}

			.text {
				color: #CCCCCC;
				font-size: 30rpx;
			}
		}
	}
</style>
